<?php
defined('_JEXEC') or die('Restricted access'); 

jimport( 'joomla.html.html.tabs' );
JHtml::_('jquery.framework');
JHtml::_('behavior.keepalive');
JHTML::_('behavior.tooltip'); 
JHtml::_('behavior.framework');

?>
<script type="text/javascript">
	//<![CDATA[
	Joomla.submitbutton = function(pressbutton){
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		if (pressbutton == 'save') {
			if (document.adminForm.title.value == "") {
				alert( 'Must have title !' );
				document.adminForm.title.focus();
				return false;
			}
		
			if (document.adminForm.point.value == "") {
				alert( 'Must have point !' );
				document.adminForm.point.focus();
				return false;
			}
			if (isNaN(document.adminForm.point.value)) {
				alert( 'Points must have a number !' );
				document.adminForm.point.focus();
				return false;
		    }
			
			submitform( pressbutton );
		}
	}
	
</script>
<script type="text/javascript">
	
	var sectionprojects = new Array;
	var sectionclubs = new Array;
	<?php
		foreach ($this->lists['projectToClub'] as $k=>$item) {
			echo "sectionprojects[".$k."] = new Array( '$item->pid','".addslashes( $item->code )."','".addslashes( $item->name )."' );\n\t\t";
		}
	?>

	<?php 
		foreach ($this->lists['clubToOutlet'] as $k=>$item){
			echo "sectionclubs[".$k."] = new Array( '$item->cid','".addslashes( $item->code )."','".addslashes( $item->name )."' );\n\t\t";
	 	}
	 ?>
	function changeClubs( listname, source, key, orig_key, orig_val ) {
		var list = eval( 'document.adminForm.' + listname );
		// empty the list

		for (i in list.options.length) {
			list.options[i] = null;
		}

		var i = 0;
		var j = 0;
		for (x in source) {
			if (source[x][0] == key) {
				opt = new Option();
				opt.value = source[x][1];
				opt.text = source[x][2];

				if ((orig_key == key && orig_val == opt.value) || i == 0) {
					opt.selected = true;
					j = opt.value ;
				}
				list.options[i++] = opt;
			}
		}
		if(i == 0){
			opt = new Option();
			opt.value = '';
			opt.text = '- Select Clubs -';
			opt.selected = true;
			list.options[i++] = opt;
		}

		list.length = i;
		changeOutlets('o_code',sectionclubs,j,0,0);
	}
</script>
<form id="adminForm" action="<?php echo JRoute::_("index.php?option=com_wrd&controller=cpoint")?>" method="post" name="adminForm">
	<div class="row-fluid">
	    <fieldset class="adminform">
	    	<legend><?php echo JText::_('Details')?></legend>
			<table class="table table-striped adminlist">
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Title')?>:</label>
					</td>
					<td colspan="2">
						<input type="text" title="type" maxlength="50" size="50" value="<?php echo $this->data->title; ?>" id="title" name="title" class="title"/> *
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Projects')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['projects']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Clubs')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['clubs']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Outlets')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['outlets']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Publish up')?>:</label>
					</td>
					<td colspan="2">
						 <?php echo JHTML::_( 'calendar', ($this->data->published_up != '0000-00-00') ? $this->data->published_up : '' , 'published_up', 'published_up','%Y-%m-%d'); ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Publish down')?>:</label>
					</td>
					<td colspan="2">
						 <?php echo JHTML::_( 'calendar', ($this->data->published_down != '0000-00-00') ? $this->data->published_down : '' , 'published_down', 'published_down','%Y-%m-%d'); ?>
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Date')?>:</label>
					</td>
					<td valign='middle'>
						<table class="table table-striped adminlist">
							<tr>
								<td>
									<input type="checkbox" title="repeat" value="1" class="mon_r" name="mon_r" class="mon_r" <?php if($this->data->mon_r){ echo "checked='checked'" ; }?> />
								</td>
								<td>Monday</td>
								
								
								<td>
									<input type="checkbox" title="repeat" value="1" class="tue_r" name="tue_r" class="tue_r" <?php if($this->data->tue_r){ echo "checked='checked'" ; }?> />
								</td>
								<td>Tuesday</td>
								
								
								<td>	
									<input type="checkbox" title="repeat" value="1" id="wed_r" name="wed_r" class="wed_r" <?php if($this->data->wed_r){ echo "checked='checked'" ; }?> />
								</td>
								<td>Wednesday</td>
								
								
								<td>
									<input type="checkbox" title="repeat" value="1" id="thu_r" name="thu_r" class="thu_r" <?php if($this->data->thu_r){ echo "checked='checked'" ; }?> />
								</td>
								<td>Thursday</td>
							
								<td>
									<input type="checkbox" title="repeat" value="1" id="fri_r" name="fri_r" class="fri_r" <?php if($this->data->fri_r){ echo "checked='checked'" ; }?> /> 
								</td>
								<td>Friday</td>
								
								
								<td>
									<input type="checkbox" title="repeat" value="1" id="sat_r" name="sat_r" class="sat_r" <?php if($this->data->sat_r){ echo "checked='checked'" ; }?> /> 
								</td>
								<td>Saturday</td>
								
								
								<td>
									<input type="checkbox" title="repeat" value="1" id="sun_r" name="sun_r" class="sun_r" <?php if($this->data->sun_r){ echo "checked='checked'" ; }?> /> 
								</td>
								<td>Sunday</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Points')?>:</label>
					</td>
					<td colspan="2">
						<input type="text" title="type" maxlength="50" size="50" value="<?php echo $this->data->point; ?>" id="point" name="point" class="point"/> *
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Gender')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['gender'] ; ?>
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Time')?>:</label>
					</td>
					<td colspan="2">
						<div style="height: 45px;width: 500px;">
							Morning:<br />
							<input type="checkbox" value="1" id="m" name="m" class="m" <?php if($this->data->m){ echo "checked='checked'" ; }?> /> 
							<?php echo JHTML::_('wrd.listHours','f_m_hour',$this->data->f_m_hour,'','f_m_hour',6); echo JHTML::_('wrd.listHours','t_m_hour',$this->data->t_m_hour,'','t_m_hour',0); ?>
						</div>
						<br>
						<div style="height: 45px;width: 500px;">
							Afternoon:<br />
							<input type="checkbox" value="1" id="a" name="a" class="a" <?php if($this->data->a){ echo "checked='checked'" ; }?> /> 
							<?php echo JHTML::_('wrd.listHours','f_a_hour',$this->data->f_a_hour,'','f_a_hour',0); echo JHTML::_('wrd.listHours','t_a_hour',$this->data->t_e_hour,'','t_a_hour',0); ?>
						</div>
						<br>
						<div style="height: 45px;width: 500px;">
							Evening:<br />
							<input type="checkbox" value="1" id="e" name="e" class="e" <?php if($this->data->e){ echo "checked='checked'" ; }?> /> 
							<?php echo JHTML::_('wrd.listHours','f_e_hour',$this->data->f_e_hour,'','f_e_hour',0); echo JHTML::_('wrd.listHours','t_e_hour',$this->data->t_e_hour,'','t_e_hour',0); ?>
						</div>
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Type')?>:</label>
					</td>
					<td colspan="2">
						<table class="table table-striped adminlist">
							<tr>
								<td>
									<input type="checkbox" value="1" id="f" name="f" class="f" <?php if($this->data->f){ echo "checked='checked'" ; }?> />
								</td>
								<td>Food</td>
								<td>
									<input type="checkbox" value="1" id="b" name="b" class="b" <?php if($this->data->b){ echo "checked='checked'" ; }?> />
								</td>
								<td>Beverage</td>
								
								<td>
									<input type="checkbox" value="1" id="o" name="o" class="o" <?php if($this->data->o){ echo "checked='checked'" ; }?> />
								</td>
								<td>Other</td>
							</tr>
							
						</table>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Publish')?>:</label>
					</td>
					<td colspan="2">
						<?php echo $this->lists['published']; ?>
					</td>
				</tr>
            </table>
		</fieldset>
	</div>
	
	<input type="hidden" name="created_id" value="<?php echo $this->user->id;?>" />
	<input type="hidden" name="controller" value="cpoint" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="id" value="<?php echo (int)$this->data->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
